<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<button onclick="startLocationReceiver()">start</button>
<button onclick="removeLocationReceiver()">remove</button>
<script>
function FlutterInvoker() {
    let variableNum = 0
    window.flutterBridgeEventObj = {}
    this.call = function (method, data, callBack) {
        variableNum++
        window.flutterBridgeEventObj[`callBack${variableNum}`] = callBack
        const postData = JSON.stringify({
            method,
            data: JSON.stringify(data),
            callback: `window.flutterBridgeEventObj.callBack${variableNum}`
        })
        // call flutter api
        try {
            FlutterApi.postMessage(postData);
        } catch (_) {
        }
    }
}
window.FlutterInvoker = new FlutterInvoker();
function startLocationReceiver() {
    FlutterInvoker.call("startLocationReceiver", {"type":0}, (data) => {
        alert(data);
    })
}
function removeLocationReceiver() {
    FlutterInvoker.call("removeLocationReceiver", {"type":0}, (data) => {
        alert(data);
    })
}
</script>
</body>
</html>